<template>
  <div class="msg">
    <div v-show="visible && type === 'success'" class="success">{{txt}}</div>
    <div v-show="visible && type === 'error'" class="error">{{txt}}</div>
    <p class="msg-bg" v-show="visible"></p>
  </div>
</template>

<script>
export default {
  data() {
    return {
      txt: "",
      type: "",
      visible: false,
    };
  },
};
</script>


<style scoped>
.msg div {
  position: fixed;
  width: 96%;
  left: 2%;
  top: 2vw;
  text-align: center;
  z-index: 9999;
  padding: 14px 20px;
  border-radius: 6px;
  color: #fff;
  font-size: 15px;
  box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.3);
}
.success {
  background: #4caf50;
}

.error {
  background: #ff5252;
}

.msg-bg {
  display: block;
  position: fixed;
  width: 100vw;
  height: 100vh;
  left: 0;
  top: 0;
  z-index: 9998;
  background-color: rgba(0, 0, 0, 0.3);
}
</style>